﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_user_DeleteUser : System.Web.UI.Page
{
    User user = null;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ltrInfo.Text = "hide";
        }
    }

    protected void btnSearch_Click(object sender, EventArgs e)
    {
        ltrInfo.Text = "";
        user = (from item in ApplicationGlobalVariables.KillDaBugsDatabase.Users
                where item.Username == txtUserName.Text
                select item).Single();
        txtFullName.Text = user.Fullname;
        txtEmail.Text = user.Email;
        txtCustomeInfo.Text = user.CustomInfo;
        txtOrganization.Text = user.Organization;
        chbReciveEmail.Checked = user.EnableEmailNotification;
    }

    protected void btndelete_Click(object sender, EventArgs e)
    {
        UserManagement usermanage = new UserManagement(UserManagement.GetCurrentUsername());
        bool result = usermanage.DeleteUser(txtUserName.Text);
        if (result == true)
        {
            ltrmess.Text = "Delete successfully!!!";
        }
        else
        {
            ltrmess.Text = "Fail!!!";
        }
        ltrInfo.Text = "hide";
    }
}